package wangyunlong.controller;

import wangyunlong.entity.Page;
import wangyunlong.entity.PageUtils;
import wangyunlong.entity.WYLBjEntity;
import wangyunlong.entity.WangYunLEntity;
import wangyunlong.service.WangYunLService;

import javax.annotation.Resource;

import java.util.List;

public class WangYunLController {
    //王云龙
    Page page = null;
    WangYunLEntity wangYunLEntity=null;
    String name = null;
    Integer pageNo = null;
    List<WYLBjEntity> wylBjEntity=null;
    String flag = "0";
    @Resource
    WangYunLService wangYunLService;
    public String queryPage(){
        //总条数
        int totalCount = wangYunLService.queryCount(name);
        //实现一个分页查询功能,计算
        page =  PageUtils.getPage(5,totalCount,pageNo);
        List<WangYunLEntity> list =wangYunLService.queryPage(page,name);
        page.setData(list);
        return "queryPage";
    }
    public String save(){
        wangYunLService.save(wangYunLEntity);
        flag = "1";
        return "save";
    }
    public String edit(){
        wangYunLEntity =  wangYunLService.edit(wangYunLEntity);
        return "edit";
    }
    public String del(){
        wangYunLService.del(wangYunLEntity);
        flag = "1";
        return "save";
    }
    public String bj(){
        wylBjEntity=wangYunLService.bj();
        return "bj";
    }

    public List<WYLBjEntity> getWylBjEntity() {
        return wylBjEntity;
    }

    public void setWylBjEntity(List<WYLBjEntity> wylBjEntity) {
        this.wylBjEntity = wylBjEntity;
    }

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }

    public WangYunLEntity getWangYunLEntity() {
        return wangYunLEntity;
    }

    public void setWangYunLEntity(WangYunLEntity wangYunLEntity) {
        this.wangYunLEntity = wangYunLEntity;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }
}
